#pragma once
// MESSAGE KALMAN_DATA_Z PACKING

#define MAVLINK_MSG_ID_KALMAN_DATA_Z 23

MAVPACKED(
typedef struct __mavlink_kalman_data_z_t {
 float zk[6]; /*<  measure observe*/
 float hk[6]; /*<  measure prediction*/
 float vk[6]; /*<  measure deviation*/
 float R[6]; /*<  measure noise*/
 float lambda[6]; /*<   Strong tracking filter lambda */
 float P0[13]; /*<  covariance*/
}) mavlink_kalman_data_z_t;

#define MAVLINK_MSG_ID_KALMAN_DATA_Z_LEN 172
#define MAVLINK_MSG_ID_KALMAN_DATA_Z_MIN_LEN 172
#define MAVLINK_MSG_ID_23_LEN 172
#define MAVLINK_MSG_ID_23_MIN_LEN 172

#define MAVLINK_MSG_ID_KALMAN_DATA_Z_CRC 215
#define MAVLINK_MSG_ID_23_CRC 215

#define MAVLINK_MSG_KALMAN_DATA_Z_FIELD_ZK_LEN 6
#define MAVLINK_MSG_KALMAN_DATA_Z_FIELD_HK_LEN 6
#define MAVLINK_MSG_KALMAN_DATA_Z_FIELD_VK_LEN 6
#define MAVLINK_MSG_KALMAN_DATA_Z_FIELD_R_LEN 6
#define MAVLINK_MSG_KALMAN_DATA_Z_FIELD_LAMBDA_LEN 6
#define MAVLINK_MSG_KALMAN_DATA_Z_FIELD_P0_LEN 13

#if MAVLINK_COMMAND_24BIT
#define MAVLINK_MESSAGE_INFO_KALMAN_DATA_Z { \
    23, \
    "KALMAN_DATA_Z", \
    6, \
    {  { "zk", NULL, MAVLINK_TYPE_FLOAT, 6, 0, offsetof(mavlink_kalman_data_z_t, zk) }, \
         { "hk", NULL, MAVLINK_TYPE_FLOAT, 6, 24, offsetof(mavlink_kalman_data_z_t, hk) }, \
         { "vk", NULL, MAVLINK_TYPE_FLOAT, 6, 48, offsetof(mavlink_kalman_data_z_t, vk) }, \
         { "R", NULL, MAVLINK_TYPE_FLOAT, 6, 72, offsetof(mavlink_kalman_data_z_t, R) }, \
         { "lambda", NULL, MAVLINK_TYPE_FLOAT, 6, 96, offsetof(mavlink_kalman_data_z_t, lambda) }, \
         { "P0", NULL, MAVLINK_TYPE_FLOAT, 13, 120, offsetof(mavlink_kalman_data_z_t, P0) }, \
         } \
}
#else
#define MAVLINK_MESSAGE_INFO_KALMAN_DATA_Z { \
    "KALMAN_DATA_Z", \
    6, \
    {  { "zk", NULL, MAVLINK_TYPE_FLOAT, 6, 0, offsetof(mavlink_kalman_data_z_t, zk) }, \
         { "hk", NULL, MAVLINK_TYPE_FLOAT, 6, 24, offsetof(mavlink_kalman_data_z_t, hk) }, \
         { "vk", NULL, MAVLINK_TYPE_FLOAT, 6, 48, offsetof(mavlink_kalman_data_z_t, vk) }, \
         { "R", NULL, MAVLINK_TYPE_FLOAT, 6, 72, offsetof(mavlink_kalman_data_z_t, R) }, \
         { "lambda", NULL, MAVLINK_TYPE_FLOAT, 6, 96, offsetof(mavlink_kalman_data_z_t, lambda) }, \
         { "P0", NULL, MAVLINK_TYPE_FLOAT, 13, 120, offsetof(mavlink_kalman_data_z_t, P0) }, \
         } \
}
#endif

/**
 * @brief Pack a kalman_data_z message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 *
 * @param zk  measure observe
 * @param hk  measure prediction
 * @param vk  measure deviation
 * @param R  measure noise
 * @param lambda   Strong tracking filter lambda 
 * @param P0  covariance
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_kalman_data_z_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
                               const float *zk, const float *hk, const float *vk, const float *R, const float *lambda, const float *P0)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_KALMAN_DATA_Z_LEN];

    _mav_put_float_array(buf, 0, zk, 6);
    _mav_put_float_array(buf, 24, hk, 6);
    _mav_put_float_array(buf, 48, vk, 6);
    _mav_put_float_array(buf, 72, R, 6);
    _mav_put_float_array(buf, 96, lambda, 6);
    _mav_put_float_array(buf, 120, P0, 13);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_KALMAN_DATA_Z_LEN);
#else
    mavlink_kalman_data_z_t packet;

    mav_array_memcpy(packet.zk, zk, sizeof(float)*6);
    mav_array_memcpy(packet.hk, hk, sizeof(float)*6);
    mav_array_memcpy(packet.vk, vk, sizeof(float)*6);
    mav_array_memcpy(packet.R, R, sizeof(float)*6);
    mav_array_memcpy(packet.lambda, lambda, sizeof(float)*6);
    mav_array_memcpy(packet.P0, P0, sizeof(float)*13);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_KALMAN_DATA_Z_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_KALMAN_DATA_Z;
    return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_KALMAN_DATA_Z_MIN_LEN, MAVLINK_MSG_ID_KALMAN_DATA_Z_LEN, MAVLINK_MSG_ID_KALMAN_DATA_Z_CRC);
}

/**
 * @brief Pack a kalman_data_z message on a channel
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message will be sent over
 * @param msg The MAVLink message to compress the data into
 * @param zk  measure observe
 * @param hk  measure prediction
 * @param vk  measure deviation
 * @param R  measure noise
 * @param lambda   Strong tracking filter lambda 
 * @param P0  covariance
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_kalman_data_z_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
                               mavlink_message_t* msg,
                                   const float *zk,const float *hk,const float *vk,const float *R,const float *lambda,const float *P0)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_KALMAN_DATA_Z_LEN];

    _mav_put_float_array(buf, 0, zk, 6);
    _mav_put_float_array(buf, 24, hk, 6);
    _mav_put_float_array(buf, 48, vk, 6);
    _mav_put_float_array(buf, 72, R, 6);
    _mav_put_float_array(buf, 96, lambda, 6);
    _mav_put_float_array(buf, 120, P0, 13);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_KALMAN_DATA_Z_LEN);
#else
    mavlink_kalman_data_z_t packet;

    mav_array_memcpy(packet.zk, zk, sizeof(float)*6);
    mav_array_memcpy(packet.hk, hk, sizeof(float)*6);
    mav_array_memcpy(packet.vk, vk, sizeof(float)*6);
    mav_array_memcpy(packet.R, R, sizeof(float)*6);
    mav_array_memcpy(packet.lambda, lambda, sizeof(float)*6);
    mav_array_memcpy(packet.P0, P0, sizeof(float)*13);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_KALMAN_DATA_Z_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_KALMAN_DATA_Z;
    return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_KALMAN_DATA_Z_MIN_LEN, MAVLINK_MSG_ID_KALMAN_DATA_Z_LEN, MAVLINK_MSG_ID_KALMAN_DATA_Z_CRC);
}

/**
 * @brief Encode a kalman_data_z struct
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 * @param kalman_data_z C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_kalman_data_z_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_kalman_data_z_t* kalman_data_z)
{
    return mavlink_msg_kalman_data_z_pack(system_id, component_id, msg, kalman_data_z->zk, kalman_data_z->hk, kalman_data_z->vk, kalman_data_z->R, kalman_data_z->lambda, kalman_data_z->P0);
}

/**
 * @brief Encode a kalman_data_z struct on a channel
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message will be sent over
 * @param msg The MAVLink message to compress the data into
 * @param kalman_data_z C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_kalman_data_z_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_kalman_data_z_t* kalman_data_z)
{
    return mavlink_msg_kalman_data_z_pack_chan(system_id, component_id, chan, msg, kalman_data_z->zk, kalman_data_z->hk, kalman_data_z->vk, kalman_data_z->R, kalman_data_z->lambda, kalman_data_z->P0);
}

/**
 * @brief Send a kalman_data_z message
 * @param chan MAVLink channel to send the message
 *
 * @param zk  measure observe
 * @param hk  measure prediction
 * @param vk  measure deviation
 * @param R  measure noise
 * @param lambda   Strong tracking filter lambda 
 * @param P0  covariance
 */
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

static inline void mavlink_msg_kalman_data_z_send(mavlink_channel_t chan, const float *zk, const float *hk, const float *vk, const float *R, const float *lambda, const float *P0)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_KALMAN_DATA_Z_LEN];

    _mav_put_float_array(buf, 0, zk, 6);
    _mav_put_float_array(buf, 24, hk, 6);
    _mav_put_float_array(buf, 48, vk, 6);
    _mav_put_float_array(buf, 72, R, 6);
    _mav_put_float_array(buf, 96, lambda, 6);
    _mav_put_float_array(buf, 120, P0, 13);
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_KALMAN_DATA_Z, buf, MAVLINK_MSG_ID_KALMAN_DATA_Z_MIN_LEN, MAVLINK_MSG_ID_KALMAN_DATA_Z_LEN, MAVLINK_MSG_ID_KALMAN_DATA_Z_CRC);
#else
    mavlink_kalman_data_z_t packet;

    mav_array_memcpy(packet.zk, zk, sizeof(float)*6);
    mav_array_memcpy(packet.hk, hk, sizeof(float)*6);
    mav_array_memcpy(packet.vk, vk, sizeof(float)*6);
    mav_array_memcpy(packet.R, R, sizeof(float)*6);
    mav_array_memcpy(packet.lambda, lambda, sizeof(float)*6);
    mav_array_memcpy(packet.P0, P0, sizeof(float)*13);
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_KALMAN_DATA_Z, (const char *)&packet, MAVLINK_MSG_ID_KALMAN_DATA_Z_MIN_LEN, MAVLINK_MSG_ID_KALMAN_DATA_Z_LEN, MAVLINK_MSG_ID_KALMAN_DATA_Z_CRC);
#endif
}

/**
 * @brief Send a kalman_data_z message
 * @param chan MAVLink channel to send the message
 * @param struct The MAVLink struct to serialize
 */
static inline void mavlink_msg_kalman_data_z_send_struct(mavlink_channel_t chan, const mavlink_kalman_data_z_t* kalman_data_z)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    mavlink_msg_kalman_data_z_send(chan, kalman_data_z->zk, kalman_data_z->hk, kalman_data_z->vk, kalman_data_z->R, kalman_data_z->lambda, kalman_data_z->P0);
#else
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_KALMAN_DATA_Z, (const char *)kalman_data_z, MAVLINK_MSG_ID_KALMAN_DATA_Z_MIN_LEN, MAVLINK_MSG_ID_KALMAN_DATA_Z_LEN, MAVLINK_MSG_ID_KALMAN_DATA_Z_CRC);
#endif
}

#if MAVLINK_MSG_ID_KALMAN_DATA_Z_LEN <= MAVLINK_MAX_PAYLOAD_LEN
/*
  This varient of _send() can be used to save stack space by re-using
  memory from the receive buffer.  The caller provides a
  mavlink_message_t which is the size of a full mavlink message. This
  is usually the receive buffer for the channel, and allows a reply to an
  incoming message with minimum stack space usage.
 */
static inline void mavlink_msg_kalman_data_z_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan,  const float *zk, const float *hk, const float *vk, const float *R, const float *lambda, const float *P0)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char *buf = (char *)msgbuf;

    _mav_put_float_array(buf, 0, zk, 6);
    _mav_put_float_array(buf, 24, hk, 6);
    _mav_put_float_array(buf, 48, vk, 6);
    _mav_put_float_array(buf, 72, R, 6);
    _mav_put_float_array(buf, 96, lambda, 6);
    _mav_put_float_array(buf, 120, P0, 13);
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_KALMAN_DATA_Z, buf, MAVLINK_MSG_ID_KALMAN_DATA_Z_MIN_LEN, MAVLINK_MSG_ID_KALMAN_DATA_Z_LEN, MAVLINK_MSG_ID_KALMAN_DATA_Z_CRC);
#else
    mavlink_kalman_data_z_t *packet = (mavlink_kalman_data_z_t *)msgbuf;

    mav_array_memcpy(packet->zk, zk, sizeof(float)*6);
    mav_array_memcpy(packet->hk, hk, sizeof(float)*6);
    mav_array_memcpy(packet->vk, vk, sizeof(float)*6);
    mav_array_memcpy(packet->R, R, sizeof(float)*6);
    mav_array_memcpy(packet->lambda, lambda, sizeof(float)*6);
    mav_array_memcpy(packet->P0, P0, sizeof(float)*13);
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_KALMAN_DATA_Z, (const char *)packet, MAVLINK_MSG_ID_KALMAN_DATA_Z_MIN_LEN, MAVLINK_MSG_ID_KALMAN_DATA_Z_LEN, MAVLINK_MSG_ID_KALMAN_DATA_Z_CRC);
#endif
}
#endif

#endif

// MESSAGE KALMAN_DATA_Z UNPACKING


/**
 * @brief Get field zk from kalman_data_z message
 *
 * @return  measure observe
 */
static inline uint16_t mavlink_msg_kalman_data_z_get_zk(const mavlink_message_t* msg, float *zk)
{
    return _MAV_RETURN_float_array(msg, zk, 6,  0);
}

/**
 * @brief Get field hk from kalman_data_z message
 *
 * @return  measure prediction
 */
static inline uint16_t mavlink_msg_kalman_data_z_get_hk(const mavlink_message_t* msg, float *hk)
{
    return _MAV_RETURN_float_array(msg, hk, 6,  24);
}

/**
 * @brief Get field vk from kalman_data_z message
 *
 * @return  measure deviation
 */
static inline uint16_t mavlink_msg_kalman_data_z_get_vk(const mavlink_message_t* msg, float *vk)
{
    return _MAV_RETURN_float_array(msg, vk, 6,  48);
}

/**
 * @brief Get field R from kalman_data_z message
 *
 * @return  measure noise
 */
static inline uint16_t mavlink_msg_kalman_data_z_get_R(const mavlink_message_t* msg, float *R)
{
    return _MAV_RETURN_float_array(msg, R, 6,  72);
}

/**
 * @brief Get field lambda from kalman_data_z message
 *
 * @return   Strong tracking filter lambda 
 */
static inline uint16_t mavlink_msg_kalman_data_z_get_lambda(const mavlink_message_t* msg, float *lambda)
{
    return _MAV_RETURN_float_array(msg, lambda, 6,  96);
}

/**
 * @brief Get field P0 from kalman_data_z message
 *
 * @return  covariance
 */
static inline uint16_t mavlink_msg_kalman_data_z_get_P0(const mavlink_message_t* msg, float *P0)
{
    return _MAV_RETURN_float_array(msg, P0, 13,  120);
}

/**
 * @brief Decode a kalman_data_z message into a struct
 *
 * @param msg The message to decode
 * @param kalman_data_z C-struct to decode the message contents into
 */
static inline void mavlink_msg_kalman_data_z_decode(const mavlink_message_t* msg, mavlink_kalman_data_z_t* kalman_data_z)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    mavlink_msg_kalman_data_z_get_zk(msg, kalman_data_z->zk);
    mavlink_msg_kalman_data_z_get_hk(msg, kalman_data_z->hk);
    mavlink_msg_kalman_data_z_get_vk(msg, kalman_data_z->vk);
    mavlink_msg_kalman_data_z_get_R(msg, kalman_data_z->R);
    mavlink_msg_kalman_data_z_get_lambda(msg, kalman_data_z->lambda);
    mavlink_msg_kalman_data_z_get_P0(msg, kalman_data_z->P0);
#else
        uint8_t len = msg->len < MAVLINK_MSG_ID_KALMAN_DATA_Z_LEN? msg->len : MAVLINK_MSG_ID_KALMAN_DATA_Z_LEN;
        memset(kalman_data_z, 0, MAVLINK_MSG_ID_KALMAN_DATA_Z_LEN);
    memcpy(kalman_data_z, _MAV_PAYLOAD(msg), len);
#endif
}
